<template>
	<view class="home">
		<swiper indicator-dots circular>
			<swiper-item v-for="(items,index) in swipers" :key="index" >
				<image :src="items.image_src"></image>
			</swiper-item>
		</swiper>
		<!-- 导航区域 -->
		<view class="nav">
			<view @click="macketclick" class="nav_item">
				<view class="iconfont icon-ziyuan"></view>
				<text>黑马超市</text>
			</view>
			<view @click="macketclick2" class="nav_item">
				<view class="iconfont icon-guanyuwomen"></view>
				<text>联系我们</text>
			</view>
			<view @click="macketclick3" class="nav_item">
				<view class="iconfont icon-tupian"></view>
				<text>社区图片</text>
			</view>
			<view @click="macketclick4" class="nav_item">
				<view class="iconfont icon-shipin"></view>
				<text>学习视频</text>
			</view>
		</view>
		<!-- 推荐商品 -->
		<view class="hot_goods">
			<view class="tit">推荐商品</view>
			<view class="goods_list">
				<view class="goods_item">
					<image src="https://api-hmugo-web.itheima.net/pyg/banner1.png"></image>
					<view class="price">
						<text>￥2199</text>
						<text>￥2499</text>
					</view>
					<view class="name">华为手机</view>
				</view>
					<view class="goods_item">
					<image src="https://api-hmugo-web.itheima.net/pyg/banner1.png"></image>
					<view class="price">
						<text>￥2199</text>
						<text>￥2499</text>
					</view>
					<view class="name">华为手机</view>
				</view>
					<view class="goods_item">
					<image src="https://api-hmugo-web.itheima.net/pyg/banner1.png"></image>
					<view class="price">
						<text>￥2199</text>
						<text>￥2499</text>
					</view>
					<view class="name">华为手机</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			swipers:[]
			}
		},
		onLoad() {
			this.getswiper()
		},
		methods: {
			getswiper(){
				// uni.request({
				// 	url:'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
				// 	success:res =>{
				// 		if(res.data.meta.status !==200){
				// 			return uni.showToast({
				// 				title:'获取失败'
				// 			})
				// 		}
				// 		this.swipers=res.data.message
				// 		console.log(res.data);
				// 	}
				// })
				this.$myrequest({
					url:"/home/swiperdata"
				}).then((res)=>{
					this.swipers=res.data.message
				})
			},
			macketclick(){
				uni.navigateTo({
					url:'/pages/goods/goods'
				})
			},
			macketclick2(){
				uni.navigateTo({
					url:'/pages/guanyuwom/guanyuwom'
				})
			},
			macketclick3(){
				uni.navigateTo({
					url:'/pages/image/image'
				})
			},macketclick4(){
				uni.navigateTo({
					url:'/pages/vedio/vedio'
				})
			}

		}
	}
</script>

<style lang="scss">
.home{
	swiper{
		width: 750rpx;
		height: 380rpx;
		image{
		width: 100%;
		height: 100%;
	 }
	}
	.nav{
		display: flex;
		.nav_item{
			width: 25%;
			text-align: center;
			view{
				width: 120rpx;
				height: 120rpx;
				background: $shop-color;
				border-radius: 60rpx;
				margin: 10rpx auto;
				line-height: 120rpx;
				color: #fff;
				font-size: 50rpx;
			}
			.icon-tupian{
					font-size: 45rpx;
				}
			text{
				font-size: 30rpx;
			}
		}
	}
	.hot_goods{
		background-color: #eee;
		overflow: hidden;
		margin-top: 10rpx;
		.tit{
			height: 50px;
			line-height: 50px;
			color: $shop-color;
			text-align: center;
			letter-spacing: 20px;
			background-color: #fff;
			margin: 7rpx 0;
		}
		.goods_list{
			padding: 0 15rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.goods_item{
				background-color: #fff;
				margin: 10rpx 0;
				width: 355rpx;
				padding: 15rpx;
				box-sizing: border-box;
				image{
					width: 80%;
					height: 150rpx;
					display: block;
					margin: 0 auto;
				}
				.price{
					color:$shop-color;
					font-size: 30rpx;
					text:nth-child(2){
						color: #ccc;
						font-size: 28rpx;
						margin-left: 17rpx;
						text-decoration: line-through;
					}
				}
				.name{
					font-size: 28rpx;
					line-height: 50rpx;
					padding-bottom: 15rpx;
					padding-top: 10rpx;
				}
			}
		}
	}
}
	
</style>
